import rule_0 from "bpmnlint/rules/conditional-flows"; //用于检查从条件分支网关或活动传出的序列流是默认流还是附加了条件
import rule_1 from "bpmnlint/rules/end-event-required"; //检查每个作用域是否存在结束事件的规则。
import rule_2 from "bpmnlint/rules/event-sub-process-typed-start-event"; //用于检查事件子进程内的启动事件是否已键入。
import rule_3 from "bpmnlint/rules/fake-join"; //通过尝试赋予任务或事件联接语义来检查是否没有假联接被建模。用户应该为并行加入网关建模，以实现所需的行为。
import rule_4 from "bpmnlint/rules/label-required"; //一种检查标签是否存在的规则
import rule_5 from "bpmnlint/rules/no-bpmndi"; //用于检查元素是否缺少BPMNDI信息，这些元素需要BPMNDI。
import rule_6 from "bpmnlint/rules/no-complex-gateway";
import rule_7 from "bpmnlint/rules/no-disconnected"; //检测是否存在孤立的元素，即不与其他元素连接的元素
import rule_8 from "bpmnlint/rules/no-duplicate-sequence-flows"; //检测是否存在重复的连线
import rule_9 from "bpmnlint/rules/no-gateway-join-fork"; //检测是否存在网关（Gateway）的不正确使用，如未正确匹配的网关连接等
import rule_10 from "bpmnlint/rules/no-implicit-split"; //检测是否存在隐式的分支，即缺少条件或默认流的分支。
import rule_11 from "bpmnlint/rules/no-inclusive-gateway"; //检测是否存在使用了包容网关（Inclusive Gateway），因为包容网关在某些情况下可能会引起歧义
import rule_12 from "bpmnlint/rules/single-blank-start-event"; //检测是否只有一个空的开始事件，因为一个空的开始事件可能导致模型的意图不明确
import rule_13 from "bpmnlint/rules/single-event-definition"; //用于验证一个事件是否最多包含一个事件定义
import rule_14 from "bpmnlint/rules/start-event-required"; //检查每个作用域是否存在启动事件的规则。
import rule_15 from "bpmnlint/rules/sub-process-blank-start-event"; //用于检查正常子流程内的启动事件是否为空（没有事件定义）
import rule_16 from "bpmnlint/rules/superfluous-gateway"; //用于检查网关是否只有一个源和目标。这些网关是多余的，因为它们什么都不做。
import rule_17 from "bpmnlint/rules/no-overlapping-elements"; //检查两个元素是否重叠的规则，除了： 边界事件与其宿主重叠 子元素重叠/位于其父元素之上（例如，子进程中的元素）

import taskRequired from "./customLintRules/taskRequired";

const cache = {};
cache["bpmnlint/conditional-flows"] = rule_0;
cache["bpmnlint/end-event-required"] = rule_1;
cache["bpmnlint/event-sub-process-typed-start-event"] = rule_2;
cache["bpmnlint/fake-join"] = rule_3;
cache["bpmnlint/label-required"] = rule_4;
cache["bpmnlint/no-bpmndi"] = rule_5;
cache["bpmnlint/no-complex-gateway"] = rule_6;
cache["bpmnlint/no-disconnected"] = rule_7;
cache["bpmnlint/no-duplicate-sequence-flows"] = rule_8;
cache["bpmnlint/no-gateway-join-fork"] = rule_9;
cache["bpmnlint/no-implicit-split"] = rule_10;
cache["bpmnlint/no-inclusive-gateway"] = rule_11;
cache["bpmnlint/single-blank-start-event"] = rule_12;
cache["bpmnlint/single-event-definition"] = rule_13;
cache["bpmnlint/start-event-required"] = rule_14;
cache["bpmnlint/sub-process-blank-start-event"] = rule_15;
cache["bpmnlint/superfluous-gateway"] = rule_16;
cache["bpmnlint/no-overlapping-elements"] = rule_17;

cache["bpmnlint/task-required"] = taskRequired;

/**
 * A resolver that caches rules and configuration as part of the bundle,
 * making them accessible in the browser.
 */
function Resolver() {}

Resolver.prototype.resolveRule = function (pkg, ruleName) {
    const rule = cache[pkg + "/" + ruleName];

    if (!rule) {
        throw new Error("cannot resolve rule <" + pkg + "/" + ruleName + ">");
    }

    return rule;
};

Resolver.prototype.resolveConfig = function (pkg, configName) {
    throw new Error("cannot resolve config <" + configName + "> in <" + pkg + ">");
};

export const resolver = new Resolver();

export const rules = {
    "conditional-flows": "error",
    "end-event-required": "error",
    "event-sub-process-typed-start-event": "error",
    "fake-join": "warn",
    "label-required": "warn",
    "no-bpmndi": "error",
    "no-complex-gateway": "error",
    "no-disconnected": "error",
    "no-duplicate-sequence-flows": "error",
    "no-gateway-join-fork": "error",
    "no-implicit-split": "error",
    "no-inclusive-gateway": "error",
    "single-blank-start-event": "error",
    "single-event-definition": "error",
    "start-event-required": "error",
    "sub-process-blank-start-event": "error",
    "superfluous-gateway": "warn",
    "no-overlapping-elements": "error",
    "task-required": "warn"
};

export const config = {
    rules: rules
};

export default {
    resolver: resolver,
    config: config
};
